function [ time, P ] = Spectral_Perm_old( C, d )

[N, ~] = size(C);
n = N/d;

time_start = tic;
[P,~] = eigs(C,d);

for i = 1:n   
    X = -P( (i-1)*d+1:i*d , : );
    [assignment, ~] = assignmentoptimal(X);
    A = zeros(d);
    A((1:d)'+(assignment-1)*d) = 1;
    P( (i-1)*d+1:i*d , : ) = A;
end

P = P*P(1:d,:)';

time = toc(time_start);

end

